package edu.caece.langprocessor.syntax.tree.nodes;

import java.util.List;

import edu.caece.langprocessor.semantic.SimpleSymbolsTable;
import edu.caece.langprocessor.syntax.GrammarItem;
import edu.caece.langprocessor.syntax.tree.TreeNode;

public abstract class AbstractTreeNode implements TreeNode {

	private GrammarItem item;
	private SimpleSymbolsTable symbolsTable;
	private List<String> errorList;
	private List<String> warningsList;
	private int level;
	private StringBuilder code; 

	public StringBuilder getCodeBuilder() {
		return code;
	}

	public void setCodeBuilder(StringBuilder code) {
		this.code = code;
	}

	public AbstractTreeNode(GrammarItem item) {
		this.item = item;
	}

	public GrammarItem getGrammarItem() {
		return this.item;
	}

	public void setSymTable(SimpleSymbolsTable table){
		this.symbolsTable = table;
	}
	
	public void setErrorsList(List<String> errorList){
		this.errorList = errorList;
	}
	
	public void setWarningsList(List<String> warningsList){
		this.warningsList = warningsList;
	}

	public SimpleSymbolsTable getSymTable(){
		return symbolsTable;
	}
	
	public List<String> getErrorsList(){
		return errorList;
	}
	
	public List<String> getWarningsList(){
		return warningsList;
	}
	
	public void setLevel(int level){
		this.level = level;
	}
	
	public int getLevel(){
		return level;
	}
	
	
	@Override
	public String toString() {
		return this.item.toString();
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		else{
			if (obj instanceof TreeNode){
				TreeNode other = (TreeNode) obj;
				return this.getGrammarItem() == other.getGrammarItem();
			}
		}
		return false;
	}

}
 